﻿using System;

namespace Sinacor.Deployment.Setup.DataAccess
{
    public class DataBaseException : Exception
    {
        public string Command { get; private set; }

        public DataBaseException(string message)
            : base(message)
        {
        }

        public DataBaseException(string message, string command)
            : base(message)
        {
            if (string.IsNullOrEmpty(command))
                throw new ArgumentNullException("command");

            this.Command = command.Trim();
        }

        public DataBaseException(string message, string command, Exception innerException)
            : base(message, innerException)
        {
            if (string.IsNullOrEmpty(command))
                throw new ArgumentNullException("command");

            this.Command = command.Trim();
        }
        
        public override string ToString()
        {
            if (!string.IsNullOrEmpty(this.Command))
            {
                return string.Format("{0}{1}Command: {2}", base.ToString(), System.Environment.NewLine, this.Command);
            }
            else
            {
                return base.ToString();
            }
        }
    }
}
